import { useState, useEffect, useRef } from 'react';

export default function Counter() {
    const [count, setCount] = useState(10);
    const countRef = useRef(count);

    useEffect(() => {
        const timer = setInterval(() => {
            console.log('Current count:', countRef.current);
            countRef.current = countRef.current - 1; // 
            setCount(countRef.current); // 更新 state
            if (countRef.current <= 0) {
                window.location.href = '/new-path';
            }
        }, 1000);

        return () => clearInterval(timer);
    }, []);

    return <div>此页面已废弃: {count} s 后将为您自动跳转</div>

}
